angular
    .module('app.service')
    .service('WorkService', WorkService);

WorkService.$inject = ['$http','API'];
function WorkService($http,API) {
    var baseUrl = API + 'admin/works';
    this.get = get;
    this.create = create;
    this.save = save;
    this.remove = remove;
    this.active = active;
    this.list = list;
    this.levels = levels;
    this.overview = overview;

    ////////////////
    function get(workId){
        return $http.get(baseUrl+'/'+workId);
    }

    function create(work){
        return $http.post(baseUrl,work);
    }

    function save(work){
        return $http.put(baseUrl+"/" + work.id,work);
    }

    function active(work){
        return $http.patch(baseUrl +'/' + work.id);
    }

    function remove(workId){
        return $http.delete(baseUrl+"/"+workId);
    }

    function list() {
        return $http.get(baseUrl);
    }

    function levels(workId){
        return $http.get(baseUrl+'/'+workId+'/levels');
    }

    function overview(workId){
        return $http.get(baseUrl+'/'+workId+'/overview');
    }
}